using System;
using System.Collections.Generic;
using System.Text;
using NUnit.Framework;
using System.Windows.Forms;

namespace Dogfight2008.Tests
{
  [TestFixture]
  public class InGameStateFixture
  {
    public class MockGame : IGame
    {
      bool gameover = false;

      public void SetGameOver()
      {
        gameover = true;
      }

      public void PlayerOneFirePushed() { }
      public void PlayerTwoFirePushed() { }

      public void ResetGame()
      {
        gameover = false;
      }

      #region IGame Members

      public bool GameOver
      {
        get { return gameover; }
      }

      public void Tick(double deltaMS)
      {
      }

      public int PlayerOnePlanes
      {
        get { return 10; }
      }

      public int PlayerTwoPlanes
      {
        get { return 10; }
      }

      public Plane PlaneOne
      {
        get
        {
          return null;
        }
      }

      #endregion

      #region IGame Members


      public void PlayerOneLiftPushed()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      public void PlayerOneDivePushed()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      public void PlayerOneDiveReleased()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      public void PlayerOneLiftReleased()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      #endregion

      #region IGame Members


      public void PlayerTwoLiftPushed()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      public void PlayerTwoDivePushed()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      public void PlayerTwoDiveReleased()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      public void PlayerTwoLiftReleased()
      {
        throw new Exception("The method or operation is not implemented.");
      }

      #endregion

      #region IGame Members


      public void PlanePadChange(PlaneName plane, PlanePad pad, PlanePadState state)
      {
        throw new Exception("The method or operation is not implemented.");
      }

      #endregion
    }
    InGameState s;
    MockGame game;

    [SetUp]
    public void Init()
    {
      game = new MockGame();
      s = new InGameState(game);
    }

    [Test]
    public void Constr()
    {
    }

    [Test]
    public void PressingEscapeQuits()
    {
      DFState newState = s.KeyDown(Keys.Escape);
      Assert.AreEqual(DFState.PressFire, newState);
    }

    [Test]
    public void PressingOtherKeyStaysInGame()
    {
      DFState newState = s.KeyDown(Keys.Space);
      Assert.AreEqual(DFState.InGame, newState);
    }

    [Test]
    public void TickWhenGameOverTransitionsToGameOverState()
    {
      game.SetGameOver();
      DFState newState = s.Tick(1);
      Assert.AreEqual(DFState.GameOver, newState);
    }

    [Test]
    public void ThereIsNoPlane1InstanceAtStart()
    {
      Assert.IsNull(game.PlaneOne);
    }
  }
}
